/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.pui;

import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;
import coalescent.cef.event.CheckPhylogenyEvent;
import coalescent.cef.pui.pob.Builders_Coa;
import coalescent.data.K69Data;
import coalescent.phylogeny.PhylogenyAlgo;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code CheckPhylogenyEvent} using the following properties. <ul> <li>{@code coalescent.builder.K69Data.url
 * = k69data:xml//URL }<a href="coalescent/cef/pui/pob/doc-files/k69data.xml.txt">file format</a>, must accompany the <a
 * href="coalescent/cef/pui/pob/doc-files/k69data.xsd.txt">schema</a></li> <li>{@code
 * coalescent.builder.PhylogenyAlgo.algorithm}("GUSFIELD", "FOURGAMETES")</li> </ul>
 *
 * @author Susanta Tewari
 * @version 1.3.0
 * @history Created on Dec 8, 2010.
 * @since 1.3.0
 */
public final class CheckPhylogenyEventImpl extends EventImpl implements CheckPhylogenyEvent {

    /** Field description */
    private Builder<K69Data> dataBuilder;

    /** Field description */
    private Builder<PhylogenyAlgo> algorithmBuilder;

    /**
     * Constructs ...
     *
     *
     * @param props
     *
     * @throws EventConstructionException
     */
    public CheckPhylogenyEventImpl(final Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());

        dataBuilder      = Builders_Coa.of_Data_K69_File(props, null);
        algorithmBuilder = Builders_Coa.of_PhylogenyAlgo(props, null);
    }

    /**
     * Method description
     *
     *
     * @param dataBuilder
     */
    public void setDataBuilder(final Builder<K69Data> dataBuilder) {
        this.dataBuilder = dataBuilder;
    }

    /**
     * Method description
     *
     *
     * @param algorithmBuilder
     */
    public void setAlgorithmBuilder(final Builder<PhylogenyAlgo> algorithmBuilder) {
        this.algorithmBuilder = algorithmBuilder;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        final List<Class<? extends Event>> result = new ArrayList<>(2);

        result.add(CheckPhylogenyEvent.class);
        result.add(Event.class);

        return result;
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws BuilderException
     */
    @Override
    public PhylogenyAlgo getPhylogenyAlgorithm() throws BuilderException {
        return algorithmBuilder.build();
    }

    /**
     * Method description
     *
     *
     * @return
     *
     * @throws BuilderException
     */
    @Override
    public K69Data getK69Data() throws BuilderException {
        return dataBuilder.build();
    }
}
